<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="includes/top.jsp" />

<form:form modelAttribute="formCategory">
    <label for="category-title">Category title</label>
    <form:input path="title" id="category-title" />
    <input type="submit" value="Create" />
</form:form>

<c:if test="${!empty categories}">

    <form:form modelAttribute="formCategories" action="categories.htm">

        <ul id="rss-categories">
            <c:forEach var="category" items="${categories}">
                <li>
                    <c:if test="${!empty formCategories.feedId}">
                        <form:checkbox path="categoryIds" value="${category.id}" cssClass="checkbox" />
                    </c:if>
                    <h4><a href="index.htm?categoryId=${category.id}" title="${category.title}">${category.title}</a></h4>
                    <a class="remove-category" href="remove-category.htm?id=${category.id}" title="Remove category: ${category.title}">Remove</a>
                </li>
            </c:forEach>
        </ul>

        <c:if test="${!empty formCategories.feedId}">
            <form:hidden path="feedId" />
            <input type="submit" value="Relate" />
        </c:if>
        
    </form:form>

</c:if>

<jsp:include page="includes/bottom.jsp" />